package com.xuecheng.filesyetem.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.xuecheng.api.filesystem.FileSystemControllerApi;
import com.xuecheng.filesyetem.service.FileSystemService;
import com.xuecheng.framework.domain.filesystem.response.UploadFileResult;

@RestController
@RequestMapping("/filesystem")
public class FileSystemController implements FileSystemControllerApi {

    @Autowired
    FileSystemService fileSystemService;

    @Override
    @PostMapping("/upload")
    public UploadFileResult upload(@RequestParam("file") MultipartFile file, 
            @RequestParam(value = "fileTag",required = true) String fileTag, 
            @RequestParam(value = "businessKey",required = false) String businessKey, 
            @RequestParam(value = "metadata",required = false) String metadata) {
        return fileSystemService.upload(file, fileTag, businessKey, metadata);
    }

}
